<template>
  <section class="knife_container newuser-box">
    <div class="newuser-banner">
      <h1 class="big-title">邀请好友得大礼包</h1>
      <p  class="samll-title">-赶快加入刀具联盟-</p>
    </div>
    <section class="newsuser-wrapper">
      <div class="newsuser-top">
        <h3 class="title">您的邀请码</h3>
        <p class="invite-code">{{inviteCode}}</p>
        <span class="btn-bg-yellow"  v-clipboard="copyLinkUrl" @success="handleSuccess">分享给好友</span>
      </div>
      <div class="newuser-bottom">
        <h3 class="rules-title">活动规则:</h3>
        <div class="user-rules">
          <h4 class="title">一 、活动玩法</h4>
          <p class="content">1、点击“分享好友”，复制链接</p>
          <p class="content">2、发送好友，好友注册审核成功之后即可得</p>
          <p class="content">3、折扣券可在个人中心查看</p>
        </div>
        <div class="user-rules">
          <h4 class="title">二、活动奖励</h4>
          <p class="content">1、老用户可得50-1000元随机折扣券</p>
          <p class="content">2、好友注册可得相应的优惠券</p>
        </div>
        <div class="user-rules">
          <h4 class="title">三、活动时间</h4>
          <p class="content">1、永久活动</p>
        </div>
        
        <p class="explain">—刀具联盟拥有此活动的最终解释权</p>
      </div>
    </section>
    <!-- 分享码 -->
    <!-- <transition name="fade">
      <section v-if="showqrcode" class="newuser-qrcode-box">
        <div class="newuser-qrcode-wrapper">
          <i class="el-icon-circle-close-outline qrcode-close" @click="showqrcode = false"></i>
          <qrcode-vue :value="qrcodeUrl" :size="size"></qrcode-vue>
          <p class="text">
            通过微信扫一扫,将连接邀请码分享给新用户,被邀请的用户注册认证成功,您即可获得一张优惠券!
          </p>
        </div>
      </section>
    </transition> -->
  </section>
</template>
<script>
  import qrcodeVue from 'qrcode.vue'
  import {getInvitationCode} from '@/service/get-data'
  import {getCookie} from '@/config/mUntils'
  export default {
    components: {
      qrcodeVue
    },
    data () {
      return {
        size: 200,
        showqrcode: false,
        inviteCode: ''
      }
    },
    computed: {
      copyLinkUrl () {
        return `${window.location.origin}/#/register/?name= ${encodeURI(this.username)}&code=${this.inviteCode}`
      },
      username () {
        return getCookie('username')
      }
    },
    methods: {
      handleSuccess () {
        // console.log('粘贴成功')
        this.$message({
          type: 'success',
          message: '已经复制链接,分享给伙伴邀请注册获取优惠券'
        })
      },
      async fetchInvitationCode () {
        let res = await getInvitationCode()
        if (res.data.resultCode && res.data.resultCode === 2000) {
          this.inviteCode = res.data.data
        } else {
          this.$message.error(res.data.resultMsg)
        }
      }
    },
    mounted () {
      this.fetchInvitationCode()
    }
  }
</script>
<style lang="scss" scoped>
  .newuser-box{
    margin: 50px auto;
    background: #fff;
    padding-bottom: 80px;
  }
  .newuser-banner{
    text-align: center;
    padding: 50px 0 10px;
    .big-title{
      font-size: 30px;
      color: #4C4C4C;
      line-height: 50px;
      margin-bottom: 10px;
    }
    .samll-title{
      color: #8F8F8F;
      font-size: 25px;
      line-height: 30px;
    }
  }
  .newuser-rules{
    padding-left:400px;
    line-height: 2;
  }
  .newuser-invite{
    margin: 40px auto;
    width: 400px;
    padding-bottom: 50px;
    .title {
      line-height: 2;
    }
    .newuser-qrcode{
      text-align: center;
    }
    .number{
      font-size: 30px;
      font-weight: 600;
      line-height: 3;
      margin: 30px 0;
    }
  }
  .newuser-qrcode-box{
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    overflow: auto;
    margin: 0;
    z-index: 2003;
    .newuser-qrcode-wrapper{
      position: relative;
      border-radius: 10px;
      background: #fff;
      padding: 50px 15px 0;
      margin: 15% auto 0;
      height: 350px;
      width: 265px;
      text-align: center;
      .text{
        margin-top: 20px;
        text-align: left;
        line-height: 1.5;
        font-size: 12px;
      }
      .qrcode-close {
        position: absolute;
        color: #333;
        right: 5px;
        top: 5px;
        font-size: 20px;
        cursor: pointer;
      }
    }
  }
  .newsuser-wrapper{
    box-sizing: border-box;
    background: #3e3d3d;
    border-radius: 10px;
    padding: 110px 240px 20px;
    width: 808px;
    height: 685px;
    margin: 0 auto;
    background: url('../../images/newuser_bg.png') no-repeat;
    background-size: contain;
    background-position: center;
  }
  .newsuser-top{
    text-align: center;
    color: #FFE100;
        margin-top: 15px;
    .title{
      font-size: 18px;
      margin-bottom: 30px;
    }
    .invite-code{
      font-size: 36px;
      margin-bottom: 45px;
    }
  }
  .newuser-bottom{
    margin-top: 25px;
    font-size: 14px;
    padding-top: 48px;
    .rules-title{
      font-size: 16px;
      margin-bottom: 22px;
      color: #DEDEDE;
    }
    .user-rules{
      margin-bottom: 12px;
      line-height: 30px;
      .title{
        color: #DEDEDE;
        font-size: 12px;
        line-height: 17px;
        margin-bottom: 6px;
      }
      .content{
        color: #DEDEDE;
        opacity: 0.6;
        font-size: 11px;
        line-height: 16px;
        margin-bottom: 5px;
      }
    }
    .explain{
      text-align: right;
      color: #DEDEDE;
      opacity: 0.6;
      font-size: 11px;
    }
  }
  .t-center{
    text-align: center;
  }
  .btn-bg-yellow{
    display: inline-block;
    padding: 16px 0;
    width: 100%;
    text-align: center;
    border-radius: 5px;
    color: #333;
    background: #FFE100;
    font-size: 16px;
    cursor: pointer;
  }
</style>